package atguigu.demo3

/**
  * Created by lzd on 2018/11/2.
  * map to list
  *
  */
object demo3_11 {
  def main(args: Array[String]): Unit = {
    val names = List("Peter", "Paul", "Mary")

    // map 映射
    names.map(_.toUpperCase) // List("PETER", "PAUL", "MARY")

    for (n <- names) yield n.toUpperCase

    def ulcase(s: String) = Vector(s.toUpperCase(), s.toLowerCase())

    names.map(ulcase)

    // flatmap映射
    names.flatMap(ulcase)

    names.foreach(println)
  }
}
